package com.zz.hhbl.provider

import android.app.Application
import android.content.Context
import android.view.Gravity
import com.yihai.pda.config.AppRetrofitConfig
import com.zz.framework.core.Kernel
import com.zz.framework.core.toast.ActivityToast
import com.zz.framework.core.toast.ToastStrategy
import com.zz.framework.core.toast.ToastUtils
import com.zz.framework.core.toast.config.IToast
import com.zz.framework.core.toast.style.BlackRoundToastStyle
import com.zz.framework.core.utils.LogUtils
import com.zz.framework.core.utils.XPreference


/**
 * @version: V1.0
 * 默认初始化  并提供 全局 applicationContext
 */
object InitializationContextProvider {
    fun attachContext(application: Application) {
        Kernel.initRetrofitConfig(AppRetrofitConfig())
        XPreference.init(application)
        ToastUtils.init(application, object : ToastStrategy() {
            override fun createToast(application: Application): IToast {
                val toast = super.createToast(application)
                if (toast is ActivityToast) {
                    val activityToast = toast as ActivityToast
                    // 设置短 Toast 的显示时长（默认是 2000 毫秒）
                    activityToast.shortDuration = 3000
                    // 设置长 Toast 的显示时长（默认是 3500 毫秒）
                    activityToast.longDuration = 5000
                    activityToast.setGravity(Gravity.TOP,0,100)
                }
                return toast
            }
        })
        ToastUtils.setStyle(BlackRoundToastStyle())
    }
}